package com.jin.rules.service;

import com.jin.rules.entity.Order;
import org.kie.api.KieBase;
import org.kie.api.runtime.KieSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Package:com.jin.rules.service
 * @ClassName: RuleService
 * @Description:
 * @Date: 2022/12/02 15:46
 * @Author: Jin
 */
@Service
public class RuleService {
    @Autowired
    private KieBase kieBase;

    public Order executeRule(Order order){
        System.out.println(order);
        KieSession kieSession = kieBase.newKieSession();
        kieSession.insert(order);
        kieSession.fireAllRules();
        kieSession.dispose();

        return order;
    }
}
